package com.kong.consts;

import com.github.abel533.database.Dialect;

import java.util.ArrayList;
import java.util.List;

public enum DbTypeEnum {

    ORACLE,
    MYSQL,
    MARIADB,
    HSQLDB,
    POSTGRESQL,
    DB2,
    SQLSERVER;


    public static List<String> supportType() {
        List<String> supports = new ArrayList<>();
        for (DbTypeEnum dbTypeEnum : DbTypeEnum.values()) {
            supports.add(dbTypeEnum.name());
        }
        return supports;
    }

    public static Dialect getDialectByName(String name) {
        name = name.toLowerCase();
        switch (name) {
            case "oracle":
                return Dialect.ORACLE;
            case "mysql":
                return Dialect.MYSQL;
            case "mariadb":
                return Dialect.MARIADB;
            case "hsqldb":
                return Dialect.HSQLDB;
            case "postgresql":
                return Dialect.POSTGRESQL;
            case "db2":
                return Dialect.DB2;
            case "sqlserver":
                return Dialect.SQLSERVER;
        }
        return null;
    }

}
